/*    file: CWndUtil.cpp
 *    desc:
 * 
 * created: 2015-11-12
 *  author: chuanjiang.zh@qq.com
 * company: 
 */

#include "stdafx.h"
#include "CWndUtil.h"


CRect CWndUtil::getRect(CWnd* parent, UINT id)
{
    CRect rc;
    CWnd* subwnd = parent->GetDlgItem(id);
    if (subwnd)
    {
        subwnd->GetWindowRect(&rc);
        parent->ScreenToClient(&rc);
    }
    return rc;
}

void CWndUtil::setRect(CWnd* parent, UINT id, const CRect& rc)
{
    CWnd* subwnd = parent->GetDlgItem(id);
    if (!subwnd)
    {
        return;
    }

    subwnd->MoveWindow(&rc);
}

void CWndUtil::offsetRect(CWnd* parent, UINT id, int x, int y)
{
    CRect rc = getRect(parent, id);
    rc.OffsetRect(x, y);
    setRect(parent, id, rc);
}

